package com.hcg.multidatasourceofanno3.service.impl;

import com.hcg.multidatasourceofanno3.domain.User;
import com.hcg.multidatasourceofanno3.mapper.CmUserMapper;
import com.hcg.multidatasourceofanno3.service.CmUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service("cmUserService")
public class CmUserServiceImpl implements CmUserService {

    @Autowired
    private CmUserMapper cmUserMapper;

    @Override
    /*
     * @Transactional(transactionManager = "cmTransactionManager")
     * 如果这样配置的话 config 需要根据 service 写 n 个不同的 manager
     */
    /*@Transactional(transactionManager = "transactionManager")*/ // 只需要一个
    @Transactional // 不用指定 transactionManager
//    @MultiDataSource(name = "cm")
    public void saveUser(User user) {
        cmUserMapper.insert(user);
        int i  = 1/0;
//        cmUserMapper.addUser(user.getUid(),user.getNickname(),user.getName(),user.getPassword(),user.getSalt(), user.getMobile());
    }

}
